package chapter3.lessons.IOpart;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @Project ：learn_java
 * @File ：IODemo02.java
 * @IDE ：IntelliJ IDEA
 * @Author ：自由如风间
 * @Date ：2025/2/28 19:21
 * @Description ：For study.
 */

public class IODemo02 {
    public static void main(String[] args) {
        FileOutputStream fo = null;
        try {
            fo = new FileOutputStream("G:\\codes\\learn_java\\IOTestOutputFiles\\test2.txt", true);
            // 根据系统来确定换行符
            String ls = System.lineSeparator();

            String data = ls + "hello, IOStream" + ls;
            fo.write(data.getBytes());
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (fo != null) {
                try {
                    fo.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
